package com.itheima.d7_interface_demo.practice;

import java.util.ArrayList;

public class StudentServiceImpl1 implements StudentService{
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("---------全班学生信息如下---------");
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            System.out.println("姓名：" + student.getName() + "，性别" + student.getSex() + "，成绩" + student.getScore());
        }
        System.out.println("---------------------");
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        double sum = 0;
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            sum += student.getScore();
        }
        double average = sum / students.size();
        System.out.println("平均分：" + average);
    }
}
